<%--
  Created by IntelliJ IDEA.
  User: xsh
  Date: 2019/10/25
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
    <head>
        <title>商品列表</title>
        <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"/>
    </head>
    <%--private int id;
    private String goodsName;
    private BigDecimal price;
    private int typeId;
    private int unit;
    private String pictureAddress;
    private String description;
    private Date date;
    private BigDecimal stars;--%>
    <body>
        <table class="table">
            <tr>
                <th>商品序号</th>
                <th>商品名称</th>
                <th>商品类型</th>
                <th>商品价格</th>
                <th>商品描述</th>
                <th>上架日期</th>
                <th>商品星级</th>
                <shiro:hasRole name="admin">
                    <th>操作</th>
                </shiro:hasRole>
            </tr>
            <c:forEach var="goods" items="${pageInfo.list}">
                <tr>
                    <td>${goods.id}</td>
                    <td>${goods.goodsName}</td>
                    <td>${goods.typeName}</td>
                    <td>${goods.price}</td>
                    <td>${goods.description}</td>
                    <td><fmt:formatDate value="${goods.date}" pattern="yyyy-MM-dd"/></td>
                    <td>${goods.stars}</td>
                    <shiro:hasRole name="admin">
                        <td>
                            <a href="${pageContext.request.contextPath}/goods/addPage">添加</a>&nbsp;&nbsp;
                            <a href="${pageContext.request.contextPath}/goods/delete?id=${goods.id}">删除</a>&nbsp;&nbsp;
                            <a href="${pageContext.request.contextPath}/goods/updatePage?id=${goods.id}">修改</a>
                        </td>
                    </shiro:hasRole>
                </tr>
            </c:forEach>
        </table>
        <a class="btn btn-default" href="${pageContext.request.contextPath}/goods/list?pageNum=1">首页</a>
        <a class="btn btn-default" href="${pageContext.request.contextPath}/goods/list?pageNum=${pageInfo.pageNum-1>1?pageInfo.pageNum-1:1}">上一页</a>
        <c:forEach begin="${pageInfo.navigateFirstPage}" end="${pageInfo.navigateLastPage}" var="pn">
            <a class="btn btn-default" href="${pageContext.request.contextPath}/goods/list?pageNum=${pn}">${pn}</a>
        </c:forEach>
        <a class="btn btn-default" href="${pageContext.request.contextPath}/goods/list?pageNum=${pageInfo.pageNum+1<pageInfo.pages?pageInfo.pageNum+1:pageInfo.pages}">下一页</a>
        <a class="btn btn-default" href="${pageContext.request.contextPath}/goods/list?pageNum=${pageInfo.pages}">尾页</a>
    </body>
</html>
